package com.link.base.base.saleactivity.service;
/*
 * createdby: wangdawei
 * created: 2018-11-20
 * comments:
 */

import com.link.base.base.saleactivity.dao.mybatis.mapper.AccntCampMonitorMapper;
import com.link.base.base.saleactivity.model.AccntCampMonitor;
import com.link.core.basic.dao.mapper.BasicMapper;
import com.link.core.basic.service.BasicServiceImpl;
import com.link.core.util.UserUtil;
import org.springframework.stereotype.Service;


import javax.annotation.Resource;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;


@Service
public class AccntCampMonitorServiceImpl extends BasicServiceImpl<AccntCampMonitor> implements AccntCampMonitorService {

    @Resource
    private AccntCampMonitorMapper accntCampMonitorMapper;
    
    @Override
    public BasicMapper<AccntCampMonitor> getBasicMapper() {
        return accntCampMonitorMapper;
    }


    @Override
    public List<AccntCampMonitor> queryByExampleList(AccntCampMonitor accntCampMonitor) throws Exception {
        return accntCampMonitorMapper.queryByExampleList(accntCampMonitor);
    }

    /**
     * 查询客户参与活动列表
     *
     * @param record
     * @return
     * @throws Exception
     */
    @Override
    public List<AccntCampMonitor> queryListPage(AccntCampMonitor record) throws Exception {
        return accntCampMonitorMapper.queryListPage(record);
    }

    /**
     * 查询客户参与活动详情
     *
     * @param record
     * @return
     * @throws Exception
     */
    @Override
    public AccntCampMonitor queryDetailById(AccntCampMonitor record) throws Exception {
        return accntCampMonitorMapper.queryDetailById(record);
    }

    @Override
    public void insertClickRecord(Long activityId,String receiveChannel,String type) throws Exception {
        AccntCampMonitor campMonitor = new AccntCampMonitor();
        // 客户id(用户id)
        campMonitor.setAccntId(UserUtil.getUser().getId());
        // 活动id
        campMonitor.setSalAcctId(activityId);
        // 类型View
        campMonitor.setActionType(type);
        // 页面 Origin
        campMonitor.setPageTable("Origin");
        SimpleDateFormat forma = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        campMonitor.setActionTime(forma.format(new Date()));
        campMonitor.setChannel(receiveChannel);
        insert(campMonitor);
    }
}

